package com.qf.controller.advices;

import com.qf.dto.R;
import com.qf.exeptions.MybaseExeption;
import com.qf.exeptions.ResultCode;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/*
杨威
2021/12/31
13:11
*/
@ControllerAdvice
@Component
@ResponseBody
public class MyControllerAdvice {
    @ExceptionHandler(MybaseExeption.class)
    public R processMyBaseException(MybaseExeption e){
        Integer code = e.getCode();
        String message = e.getMessage();
        return R.setError(code,message);
    }

//    @ExceptionHandler(Exception.class)
//    public R processMyBaseException(Exception e){
//        return R.setError(ResultCode.FAIL,"未知异常");
//    }
}
